package com.example.trans.controller;

import com.example.trans.service.LogService;
import com.example.trans.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/user2")
@RestController
public class UserController2 {
    @Autowired
    private UserService userService;

    @Autowired
    private LogService logService;

    @Transactional
    @RequestMapping("/register")
    public Boolean register(String userName, String password) {

        Integer result = userService.register(userName,password);
        System.out.println("插入用户表，result: " + result);

        Integer logResult =  logService.register(userName,"用户注册");
        System.out.println("插入注册表，result: " + result);

        return true;
    }
}
